#!/usr/bin/env ruby
# frozen_string_literal: true

require 'yaml'

MAX_OBSERVED_FEATURE_FLAGS = 10

observed_count = Dir.glob('{config,ee/config}/feature_flags/**/*.yml').count do |file|
  YAML.load_file(file)['observed'] == true
end

if observed_count > MAX_OBSERVED_FEATURE_FLAGS
  puts "ERROR: Found #{observed_count} observed feature flags, maximum is #{MAX_OBSERVED_FEATURE_FLAGS}"
  exit 1
end
